package com.boarsoft.flow.demo.query;

import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.boarsoft.flow.core.bean.JoinHandler;

public class SumJoinHandlerImpl implements JoinHandler {
	private static final Logger log = LoggerFactory.getLogger(SumJoinHandlerImpl.class);

	@Override
	public Object join(Object flowData, Map<String, Object> resultMap) {
		String userId = (String) flowData;
		Long total = 0L;
		for (String k : resultMap.keySet()) {
			Long v = (Long) resultMap.get(k);
			total += v;
		}
		log.info("User {} total asset = {}", userId, total);
		return total;
	}

}
